package org.reliablesource.prism.gef.editor.parts;

import org.eclipse.gef.commands.Command;
import org.eclipse.gef.editpolicies.ComponentEditPolicy;
import org.eclipse.gef.requests.GroupRequest;
import org.reliablesource.prism.gef.editor.commands.PointerLocationDeleteCommand;
import org.reliablesource.prism.gef.editor.model.PointerLocation;
import org.reliablesource.prism.gef.editor.model.ScreenAdapter;

/**
 *
 *  PointerLocationComponentEditPolicy.java
 *  Copyright (c) 2006, Reliable Source, Inc. All Rights Reserved
 *
 *	This edit policy enables the removal of a PointerLocation instance from
 * 	its container.
 * 
 * @see PointerLocationEditPart#createEditPolicies()
 * @see PointerLocationTreeEditPart#createEditPolicies()
 * 
 *	Created on: Apr 24, 2006 
 *  @author Dennis Park <a href="mailto:dennis.park@gmail.com">dennis.park@gmail.com</a>
 *
 */


public class PointerLocationComponentEditPolicy extends ComponentEditPolicy{


	/*
	 * (non-Javadoc)
	 * 
	 * @see org.eclipse.gef.editpolicies.ComponentEditPolicy#createDeleteCommand(org.eclipse.gef.requests.GroupRequest)
	 */
	protected Command createDeleteCommand(GroupRequest deleteRequest) {
		Object parent = getHost().getParent().getModel();
		Object child = getHost().getModel();
		if (parent instanceof ScreenAdapter
				&& child instanceof PointerLocation) {
			return new PointerLocationDeleteCommand((ScreenAdapter) parent,
					(PointerLocation) child);
		}
		return super.createDeleteCommand(deleteRequest);
	}


}
